USE F90_UNIX_FILE
This module contains part of a Fortran API to functions detailed in ISO/IEC 9945-1:1990 Portable Operating System Interface (POSIX) - Part 1: System Application Program Interface (API) [C Language].
The functions in this module are from Section 5.6 File Characteristics.
Error handling is described in F90_UNIX_ERRNO. Note that for procedures with an optional ERRNO argument, if an error occurs and ERRNO is not present, the program will be terminated.
INTEGER,PARAMETER :: F_OKFlag for requesting file existence check (see ACCESS).
USE F90_UNIX_DIR,ONLY:MODE_KINDSee F90_UNIX_DIR for a description of this parameter.
INTEGER,PARAMETER :: R_OKFlag for requesting file readability check (see ACCESS).
INTEGER(MODE_KIND),PARAMETER :: S_IRGRPFile mode bit indicating group read permission (see STAT_T).
INTEGER(MODE_KIND),PARAMETER :: S_IROTHFile mode bit indicating other read permission (see STAT_T).
INTEGER(MODE_KIND),PARAMETER :: S_IRUSRFile mode bit indicating user read permission (see STAT_T).
INTEGER(MODE_KIND),PARAMETER :: S_IRWXGMask to select the group accessibility bits from a file mode (see STAT_T).
INTEGER(MODE_KIND),PARAMETER :: S_IRWXOMask to select the other accessibility bits from a file mode (see STAT_T).
INTEGER(MODE_KIND),PARAMETER :: S_IRWXUMask to select the user accessibility bits from a file mode (see STAT_T).
INTEGER(MODE_KIND),PARAMETER :: S_ISGIDFile mode bit indicating that the file is set-group-ID (see STAT_T).
INTEGER(MODE_KIND),PARAMETER :: S_ISUIDFile mode bit indicating that the file is set-user-ID (see STAT_T).
INTEGER(MODE_KIND),PARAMETER :: S_IWGRPFile mode bit indicating group write permission (see STAT_T).
INTEGER(MODE_KIND),PARAMETER :: S_IWOTHFile mode bit indicating other write permission (see STAT_T).
INTEGER,PARAMETER :: S_IWUSRFile mode bit indicating user write permission (see STAT_T).
INTEGER(MODE_KIND),PARAMETER :: S_IXGRPFile mode bit indicating group execute permission (see STAT_T).
INTEGER(MODE_KIND),PARAMETER :: S_IXOTHFile mode bit indicating other execute permission (see STAT_T).
INTEGER,PARAMETER :: S_IXUSRFile mode bit indicating user execute permission (see STAT_T).
USE F90_UNIX_ENV,ONLY :: TIME_KINDSee F90_UNIX_ENV for a description of this parameter.
INTEGER,PARAMETER :: W_OKFlag for requesting file writability check (see ACCESS).
INTEGER,PARAMETER :: X_OKFlag for requesting file executability check (see ACCESS).
TYPE STAT_T INTEGER(MODE_KIND) ST_MODE INTEGER(...) ST_INO INTEGER(...) ST_DEV INTEGER(...) ST_NLINK INTEGER(...) ST_UID INTEGER(...) ST_GID INTEGER(...) ST_SIZE INTEGER(TIME_KIND) ST_ATIME, ST_MTIME, ST_CTIME END TYPEDerived type holding file characteristics.
TYPE UTIMBUF INTEGER(TIME_KIND) ACTIME, MODTIME END TYPEData type holding time values for communication to UTIME. ACTIME is the new value for ST_ATIME, MODTIME is the new value for ST_MTIME.
PURE SUBROUTINE ACCESS(PATH,AMODE,ERRNO) CHARACTER*(*),INTENT(IN) :: PATH INTEGER,INTENT(IN) :: AMODE INTEGER,INTENT(OUT) :: ERRNOChecks file accessibility according to the value of AMODE; this should be F_OK or a combination of R_OK, W_OK and X_OK. In the latter case the values may be combined by addition or the IOR intrinsic.
The result of the accessibility check is returned in ERRNO, which receives zero for success (i.e. the file exists for F_OK, or all the accesses requested by the R_OK et al combination are allowed) or an error code indicating the reason for access rejection. Possible rejection codes include EACCES, ENAMETOOLONG, ENOENT, ENOTDIR, EROFS (see F90_UNIX_ERRNO).
If the value of AMODE is invalid, error EINVAL is returned.
Note that most ACCESS enquires are equivalent to an INQUIRE statement: in particular, CALL ACCESS(PATH,F_OK,ERRNO) returns success (ERRNO==0) if and only if INQUIRE(FILE=PATH,EXIST=LVAR) would set LVAR to .TRUE..
CALL ACCESS(PATH,R_OK,ERRNO) returns success (ERRNO==0) if and only if INQUIRE(FILE=PATH,READ=CHVAR) would set CHVAR to "YES".
CALL ACCESS(PATH,W_OK,ERRNO) returns success (ERRNO==0) if and only if INQUIRE(FILE=PATH,WRITE=CHVAR) would set CHVAR to "YES".
CALL ACCESS(PATH,IOR(W_OK,R_OK),ERRNO) returns success (ERRNO==0) if and only if INQUIRE(FILE=PATH,READWRITE=CHVAR) would set CHVAR to "YES". The only differences being that ACCESS returns a reason for rejection, and can test file executability.
SUBROUTINE CHMOD(PATH,MODE,ERRNO) CHARACTER*(*),INTENT(IN) :: PATH INTEGER(MODE_KIND),INTENT(IN) :: MODE INTEGER,OPTIONAL,INTENT(OUT) :: ERRNOSets the file mode (ST_MODE) to MODE.
Possible errors include EACCES, ENAMETOOLONG, ENOTDIR, EPERM, EROFS (see F90_UNIX_ERRNO).
SUBROUTINE CHOWN(PATH,OWNER,GROUP,ERRNO) CHARACTER*(*),INTENT(IN) :: PATH INTEGER,INTENT(IN) :: OWNER, GROUP INTEGER,OPTIONAL,INTENT(OUT) :: ERRNOChanges the owner (ST_UID) of file PATH to OWNER, and the group number (ST_GID) of the file to GROUP.
Possible errors include EACCES, EINVAL, ENAMETOOLONG, ENOTDIR, ENOENT, EPERM, EROFS (see F90_UNIX_ERRNO).
SUBROUTINE FSTAT(LUNIT,BUF,ERRNO) INTEGER,INTENT(IN) :: LUNIT TYPE(STAT_T),INTENT(OUT) :: BUF INTEGER,OPTIONAL,INTENT(OUT) :: ERRNOBUF receives the characteristics of the file connected to logical unit LUNIT.
If LUNIT is not a valid logical unit number or is not connected to a file, error EBADF is raised (see F90_UNIX_ERRNO).
SUBROUTINE STAT(PATH,BUF,ERRNO) CHARACTER*(*),INTENT(IN) :: PATH TYPE(STAT_T),INTENT(OUT) :: BUF INTEGER,OPTIONAL,INTENT(OUT) :: ERRNOBUF receives the characteristics of the file PATH.
Possible errors include EACCES, ENAMETOOLONG, ENOENT, ENOTDIR (see F90_UNIX_ERRNO).
f90_unix_dir(3), f90_unix_errno(3), f95(1), intro(3), nag_modules(3).
Please report any bugs found to "support@nag.co.uk", along with any suggestions for improvements.